package three;

import java.util.Scanner;

public class test8956 {
    public static int[] a;
    public static int[] f;

    public static void main(String[] args) {
        a = new int[1001];
        f = new int[1001];
        int n;
        Scanner scanner = new Scanner(System.in);
        while ((n = scanner.nextInt()) != 0) {
            for (int i = 1; i <= n; i++) {
                a[i] = scanner.nextInt();
                f[i] = 0;
            }
            Longest(n);
            System.out.println(max(n));
        }
    }

    private static void Longest(int n) {
        f[1] = 1;
        for (int i = 2; i <= n; i++) {
            if (min(i - 1) > a[i]) {
                f[i] = 1;
            } else {
                for (int j = 1; j < i; j++) {
                    if (a[j] > a[i])
                        continue;
                    else {
                        if (f[i] < f[j] + 1) {
                            f[i] = f[j] + 1;
                        }
                    }
                }
            }
        }
    }

    private static int min(int n) {
        int min = a[1];
        for (int i = 1; i <= n; i++) {
            if (min > a[i]) {
                min = a[i];
            }
        }
        return min;
    }

    private static int max(int n) {
        int max = f[1];
        for (int i = 1; i <= n; i++) {
            if (max < f[i]) {
                max = f[i];
            }
        }
        return max;
    }
}
